home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
10,000 Great Games
/
10,000 Great Games.iso
/
Product
/
66
/
data1.cab
/
Source_Files
/
Src
/
Gameloop.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-16
|
2KB
|
122 lines
#include "stdafx.h"
int end_game = TRUE;
void game_loop()
{
MSG msg;
// We're entering the game loop
end_game = FALSE;
// Acquire the mouse to rid windows of message pump
init_mouse();
// Delete editables
cEditable::delete_editables();
// Create disaster
cDisaster::make();
// Assign players
cPlayer::make();
// Play some music
play_music("MAIN", TRUE);
// Write the first frame
write_frame();
// Unpause game
cTimer::unpause();
// Enter game loop
while (!end_game)
{
if (PeekMessage(&msg, mainwindowhandle, 0, 0, PM_REMOVE))
switch (msg.message)
{
case WM_KEYDOWN:
switch (msg.wParam)
{
case VK_ESCAPE:
end_game = TRUE;
break;
case VK_PAUSE:
cTimer::togglepause();
break;
case VK_F12:
make_screenshot();
break;
default:
cTimer::unpause();
break;
}
case MM_MCINOTIFY:
if(msg.wParam == MCI_NOTIFY_SUCCESSFUL)
replay_music();
break;
case WM_PAINT:
if (inawin)
DispatchMessage(&msg);
break;
}
// Reacquire mouse if lost
acquire_mouse();
// Update frame
if (!cTimer::is_paused())
{
// Make sounds
ambient_sounds();
// Scroll the background buffer
do_scrolling();
// Control objects
control_level();
// Check end level
if (first_at_end != 0)
{
bubbles->delete_list();
players->delete_list();
scores->delete_list();
}
// Write a frame and show it
write_frame();
}
}
// Pause the timer
cTimer::pause();
// Unaquire the mouse
deinit_mouse();
}